package com.mima.minaserver.repository;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.mima.minaserver.entity.Camera;

@Repository
public interface CameraRepository extends JpaRepository<Camera,String>{
	
	@Query(value = "select * from t_camera where uuid = ?", nativeQuery = true)
	public Camera findDeviceByUUID(String UUID);
	
	@Modifying
	@Transactional
	@Query(value = "update t_camera set rtmp_url = ?1 where uuid = ?2", nativeQuery = true)
	public void updateCameraRtmpurl(String rtmpURL,String UUID);
	
	@Modifying
	@Transactional
	@Query(value = "update t_camera set status = ?1 where uuid = ?2", nativeQuery = true)
	public void updateStatusByUUID(int status, String UUID);
	
	@Modifying
	@Transactional
	@Query(value = "update t_camera set opened = ?1 where uuid = ?2", nativeQuery = true)
	public void updateOpened(int opened, String UUID);

}
